﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TRPOP.Common;

namespace TRPOP.CMS.Model
{

    /// <summary>
    /// 附件设置信息
    /// </summary>
    [Serializable]
    public class AttachmentSettingInfo
    {

        #region  私有变量
        bool m_DelPageWhenDelNode = false;
        bool m_DelImgWhenDelNode = false;
        bool m_DelAttrWhenDelNode = false;
        int m_UpImageSize = 1024;
        string m_UpImageType = "jpg|jpeg|png|gif";
        bool m_PreserverAspectRatio = false;
        string m_ImgReSave = "100*70,140*105,90*65";
        int m_UpImageMaxWidth = 1000;
        int m_UpAttachSize = 1024;
        string m_UpAttachType = "zip|rar|doc|xls";
        string m_UploadFileNameReg = "Y/md";
        #endregion

        #region 成员函数
        /// <summary>
        /// 永久删除结点时，删除发布页面 
        /// </summary>
        public bool DelPageWhenDelNode
        {
            get
            {
                return m_DelPageWhenDelNode;
            }
            set
            {
                m_DelPageWhenDelNode = value;
            }
        }

        /// <summary>
        /// 永久删除结点或信息时，删除上传图片
        /// </summary>
        public bool DelImgWhenDelNode
        {
            get
            {
                return m_DelImgWhenDelNode;
            }
            set
            {
                m_DelImgWhenDelNode = value;
            }
        }

        /// <summary>
        /// 永久删除结点或信息时，删除上传附件
        /// </summary>
        public bool DelAttrWhenDelNode
        {
            get
            {
                return m_DelAttrWhenDelNode;
            }
            set
            {
                m_DelAttrWhenDelNode = value;
            }
        }

        /// <summary>
        /// 上传图片大小限制(字节)
        /// </summary>
        public int UpImageSize
        {
            get
            {
                return m_UpImageSize;
            }
            set
            {
                m_UpImageSize = value;
            }
        }

        /// <summary>
        /// 上传图片类型限制
        /// </summary>
        public string UpImageType
        {
            get
            {
                return m_UpImageType;
            }
            set
            {
                m_UpImageType = value;
            }
        }

        /// <summary>
        /// 图片压缩是否等比压缩（即：(留白)不损失原图质量）
        /// </summary>
        public bool PreserverAspectRatio
        {
            get
            {
                return m_PreserverAspectRatio;
            }
            set
            {
                m_PreserverAspectRatio = value;
            }
        }

        /// <summary>
        /// 上传图片压缩缩略图列表
        /// </summary>
        public string ImgReSave
        {
            get
            {
                return m_ImgReSave;
            }
            set
            {
                m_ImgReSave = value;
            }
        }

        /// <summary>
        /// 上传图片的宽度限制，大于此宽度则自动压缩
        /// </summary>
        public int UpImageMaxWidth
        {
            get
            {
                return m_UpImageMaxWidth;
            }
            set
            {
                m_UpImageMaxWidth = value;
            }
        }

        /// <summary>
        /// 上传附件大小限制
        /// </summary>
        public int UpAttachSize
        {
            get
            {
                return m_UpAttachSize;
            }
            set
            {
                m_UpAttachSize = value;
            }
        }

        /// <summary>
        /// 上传附件类型限制
        /// </summary>
        public string UpAttachType
        {
            get
            {
                return m_UpAttachType;
            }
            set
            {
                m_UpAttachType = value;
            }
        }

        /// <summary>
        /// 文件上传命名规则
        /// </summary>
        public string UploadFileNameReg
        {
            get
            {
                return m_UploadFileNameReg;
            }
            set
            {
                m_UploadFileNameReg = value;
            }
        }
        #endregion

    }
}
/*
    /// <summary>
    /// 附件配置信息帮助方法
    /// </summary>
    public static class AttachmentSettingInfoHelper
    {
        static AttachmentSettingInfo mAttachmentInfo;
        static string m_AttachmentConfigFileName = Common.Util.GetMapPath(SystemConst.ConfigRootName + SystemConst.SystemParam_AttachmentFileName);
        
        /// <summary>
        /// 获取附件配置信息
        /// </summary>
        public static AttachmentSettingInfo AttachmentSetting
        {
            get
            {
                if (mAttachmentInfo != null)
                {
                    return mAttachmentInfo;
                }
                else
                {

                    if (FileUtil.IsExist(m_AttachmentConfigFileName))
                    {
                        mAttachmentInfo = SerializationHelper.Load(typeof(AttachmentSettingInfo), m_AttachmentConfigFileName) as AttachmentSettingInfo;
                    }

                    if (mAttachmentInfo == null)
                    {
                        mAttachmentInfo = new AttachmentSettingInfo();

                        SerializationHelper.Save(mAttachmentInfo, m_AttachmentConfigFileName);
                    }

                    return mAttachmentInfo;
                }
            }
        }

        /// <summary>
        /// 保存附件配置信息
        /// </summary>
        /// <param name="oAttachmentInfo"></param>
        public static void SaveAttachment(AttachmentSettingInfo oAttachmentInfo)
        {
            mAttachmentInfo = oAttachmentInfo;
            SerializationHelper.Save(mAttachmentInfo, m_AttachmentConfigFileName);
        }
    }
    */
